package com.ruoyi.web.core.config;

import com.github.jaemon.dinger.DingerSender;
import com.github.jaemon.dinger.support.CustomMessage;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;

import java.text.MessageFormat;

/**
 * @author Xs.Tao
 */

@PropertySource("classpath:dinger.properties")
@Configuration
public class DingerConfig implements CommandLineRunner {
    @Autowired
    private ObjectProvider<DingerSender> dingerSender;

    @Bean
    public CustomMessage markDownMessage(Environment environment) {

        return (projectId, request) ->
                MessageFormat.format(
                        "#### 【通知】 - 项目名称: {0} {1}环境\n-  内容: {2}",
                        projectId,environment.getProperty("spring.profiles.active"), request.getContent());
    }


    public void push(){

    }

    @Override
    public void run(String... args) throws Exception {
   
    }
}
